package com.yueka.mapper;

import com.yueka.pojo.classroom.Classroom;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClassroomMapper {
    @Select("select id, classroom_name, avatar, description, status, create_time, update_time from classroom")
    List<Classroom> list();

    @Insert("insert into classroom(classroom_name, avatar, description, status, create_time, update_time) values(#{classroomName}, #{avatar}, #{description}, #{status}, #{createTime}, #{updateTime})")
    void insert(Classroom classroom);

    @Update("update classroom set classroom_name = #{classroomName}, avatar = #{avatar}, description = #{description}, status = #{status}, update_time = #{updateTime} where id = #{id}")
    void update(Classroom classroom);

    @Select("select count(*) from course where classroom_id = #{id}")
    int isUsed(Integer id);

    @Delete("delete from classroom where id = #{id}")
    void delete(Integer id);

    @Select("select id, classroom_name, avatar, description, status, create_time, update_time from classroom where status = '1'")
    List<Classroom> getClassroom();
}
